/**
 * 应用中心-服务配置mock拦截,
 * 方法集
 * create by xyr on 2017-09-20
 */

import Mock from 'mockjs';


const getConfigList = [];
const count = 33;

// 初始化用户查询list数据
for (let i = 0; i < count; i++) {
    getConfigList.push(Mock.mock({
        configMapName: '@increment',
        createTime: '2017-09-20 11:33:43',
        namespace: 'default',
        files: {
            items: [
                {
                    configMapName: '@cname',
                    fileContent: 'hello configmap',
                    fileName: 'config-1.txt',
                    namespace:'default'
                },
                {
                    configMapName: '@cname',
                    fileContent: 'hello configmap',
                    fileName: 'config-2.txt',
                    namespace:'default'
                },
                {
                    configMapName: '@cname',
                    fileContent: 'hello configmap',
                    fileName: 'config-3.txt',
                    namespace:'default'
                }
            ],
            total: 3
        }
    }));
}






export default {
    getAllConfigMap: () => {
        return {
            meta: {
                code: 200,
                message: 'success'
            },
            data: {
                total: getConfigList.length,
                configMap: getConfigList 
            }
        }
    },
    getConfigMapByNamespace: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: [
                {
                    configMapName: 'tomcat-configmap-1',
                    fileCount: 1,
                    createTime: '2017-11-10 12:22:34',
                    namespace: 'nipdev'
                },
                {
                    configMapName: 'tomcat-configmap-2',
                    fileCount: 1,
                    createTime: '2017-11-10 12:22:34',
                    namespace: 'nipdev'
                }
            ]
        }
    },
    getNamespaceCombobox: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: [
                {name: 'default'},
                {name: 'kube-system'},
                {name: 'hahahaha'},
            ]
        }
    },
    addConfigMap: () => {
        return {
            meta: {
                code: 200,
                message: 'success'
            },
            data: {}
        }
    },
    deleteConfigMap: () => {
        return {
            meta: {
                code: 200,
                message: 'success'
            },
            data: {}
        }
    },
    addConfigFile: () => {
        return {
            meta: {
                code: 200,
                message: 'success'
            },
            data: {}
        }
    },
    updateConfigFile: () => {
        return {
            meta: {
                code: 200,
                message: 'success'
            },
            data: {}
        }
    },
    deleteConfigFile: () => {
        return {
            meta: {
                code: 200,
                message: 'success'
            },
            data: {}
        }
    },
    validateConfigMap: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: 200
        }
    },
    getConfigFile: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: [
                {
                    fileName: 'config.txt',
                    createTime: '2017-11-23 11:22:34',
                    namespace: 'nipdev',
                    configMapName: 'asd',
                    fileContent: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
                },
                {
                    fileName: 'a.txt',
                    createTime: '2017-11-09 33:33:33',
                    namespace: 'nipdev',
                    configMapName: 'asd',
                    fileContent: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
                }
            ]
        }
    }
}